<?php ;

require 'featured_story_id.inc';
featured_story::init();
return;

//----------------

class featured_story {

    static function init() {
        global $pligg_vars;

        if (empty($pligg_vars['featured_story_id'])) return;
        if (! self::isFrontPage()) return;

        module_add_action_tpl(
            'tpl_pligg_above_center',
            dirname(__FILE__) . '/templates/featured_story_index.tpl');
    }

    static function isFrontPage() {
        global $script_name;

        $r = $_REQUEST;
        return
            $script_name == 'index'
            && empty($r['category'])
            && (empty($r['page']) || $r['page'] == 1)
            && (empty($r['part']) || $r['part'] == 'recent');
    }

    static function write() {
        global $pligg_vars;

        require_once mnminclude.'link.php'; // ugh
        $link = new Link;
        $link->id = $pligg_vars['featured_story_id'];
        $link->read();
        $link->print_summary('summary');
    }
}
